package etc;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Andrea
 */
public abstract class Observable {
    private final List<ModelObserver> list;

    protected Observable() {
        list = new ArrayList<>(5);
    }
    
    public void addObserver(ModelObserver o){
        list.add(o);
    }
    
    public void removeObserver(ModelObserver o){
        list.remove(o);
    }
    
    
    public void notifyObservers(){
        for (ModelObserver observer : list) {
            observer.update();
        }
    }
    
    public void notifyScoreChanged(){
        for (ModelObserver observer : list) {
            observer.updateScore();
        }
    }
    
    public void notifyGameOver(){
        for (ModelObserver observer : list) {
            observer.gameOver();
        }
    }
}
